
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
</head>
<body>
<!--匿名-->
<div sec:authorize="isAnonymous()">
    未登录，点击 <a th:href="@{/login}">登录</a>
</div>
<!--登录-->
<div sec:authorize="isAuthenticated()">
    <p>已登录</p>
    <p>登录名：<span sec:authentication="name"></span></p>
    <p>角色：<span sec:authentication="principal.authorities"></span></p>
    <p>Username：<span sec:authentication="principal.username"></span></p>
    <p>Password：<span sec:authentication="principal.password"></span></p>
    <p>Email ：<span sec:authentication="principal.email"></span></p>
    <p>Name：<span sec:authentication="principal.name"></span></p>
    <p>Status：<span sec:authentication="principal.status"></span></p>
    <p>拥有的角色：
        <span sec:authorize="hasRole('ROLE_ADMIN')">管理员</span>
        <span sec:authorize="hasRole('ROLE_USER')">用户</span>
    </p>
</div>
</body>
</html>
